from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String, Boolean, DateTime, Integer, Float

from db.db_base import BaseModel


class AccountApiKey(BaseModel):
    __tablename__ = "crewplus_account_api_key"
    __table_args__ = ({'comment': 'user created api key list'})

    user_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True, comment="user id", unique=False)
    api_key: Mapped[str] = mapped_column(String(255), nullable=False, index=True, comment="api key", unique=True)
    name: Mapped[str] = mapped_column(String(255), nullable=False, comment="api key name")
    is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="is active")
    total_usage: Mapped[int] = mapped_column(Integer, default=0, nullable=True, comment="total usage")
